﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Data;
using YouErYuanModels;
using CommonLib;
using System.Data.SqlClient;

namespace YouErYuanBLL
{
    /// <summary>
    /// 登录日志记录处理
    /// </summary>
    public class ManageLoginLogBLL
    {
        /// <summary>
        /// 记录登录日志
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="type">操作类型，1=登录，0=退出</param>
        /// <param name="beizhu">备注</param>
        /// <returns></returns>
        public int AddLoginLog(string userId, string type, string beizhu)
        {
            string sql = "INSERT INTO [dbo].[T_ManageLoginLog]([id],[loginUserId],[loginTime],[type],[beizhu]) VALUES(@id,@loginUserId,@loginTime,@type,@beizhu)";
            SqlParameter[] parmas = {
                new SqlParameter("@id",Guid.NewGuid().ToString()),
                new SqlParameter("@loginUserId",userId),
                new SqlParameter("@type",type),
                new SqlParameter("@beizhu",beizhu),
                new SqlParameter("@loginTime",DateTime.Now)
            };
            int count = SQLHepler.ExecuteSql(sql, parmas);
            return count;
        }


    }
}
